<!doctype html>
<html>
    <head>
        <title>MySQL安装手册 - Linux(EL7)</title>
        <meta charset='utf-8'/>
        <style>
 .ͼ1.cm-focused {outline: 1px dotted #212121;}
.ͼ1 {position: relative !important; box-sizing: border-box; display: flex !important; flex-direction: column;}
.ͼ1 .cm-scroller {display: flex !important; align-items: flex-start !important; font-family: monospace; line-height: 1.4; height: 100%; overflow-x: auto; position: relative; z-index: 0;}
.ͼ1 .cm-content[contenteditable=true] {-webkit-user-modify: read-write-plaintext-only;}
.ͼ1 .cm-content {margin: 0; flex-grow: 2; flex-shrink: 0; display: block; white-space: pre; word-wrap: normal; box-sizing: border-box; min-height: 100%; padding: 4px 0; outline: none;}
.ͼ1 .cm-lineWrapping {white-space: pre-wrap; white-space: break-spaces; word-break: break-word; overflow-wrap: anywhere; flex-shrink: 1;}
.ͼ2 .cm-content {caret-color: black;}
.ͼ3 .cm-content {caret-color: white;}
.ͼ1 .cm-line {display: block; padding: 0 2px 0 6px;}
.ͼ1 .cm-layer > * {position: absolute;}
.ͼ1 .cm-layer {position: absolute; left: 0; top: 0; contain: size style;}
.ͼ2 .cm-selectionBackground {background: #d9d9d9;}
.ͼ3 .cm-selectionBackground {background: #222;}
.ͼ2.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground {background: #d7d4f0;}
.ͼ3.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground {background: #233;}
.ͼ1 .cm-cursorLayer {pointer-events: none;}
.ͼ1.cm-focused > .cm-scroller > .cm-cursorLayer {animation: steps(1) cm-blink 1.2s infinite;}
@keyframes cm-blink {50% {opacity: 0;}}
@keyframes cm-blink2 {50% {opacity: 0;}}
.ͼ1 .cm-cursor, .ͼ1 .cm-dropCursor {border-left: 1.2px solid black; margin-left: -0.6px; pointer-events: none;}
.ͼ1 .cm-cursor {display: none;}
.ͼ3 .cm-cursor {border-left-color: #444;}
.ͼ1 .cm-dropCursor {position: absolute;}
.ͼ1.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor {display: block;}
.ͼ1 .cm-iso {unicode-bidi: isolate;}
.ͼ1 .cm-announced {position: fixed; top: -10000px;}
@media print {.ͼ1 .cm-announced {display: none;}}
.ͼ2 .cm-activeLine {background-color: #cceeff44;}
.ͼ3 .cm-activeLine {background-color: #99eeff33;}
.ͼ2 .cm-specialChar {color: red;}
.ͼ3 .cm-specialChar {color: #f78;}
.ͼ1 .cm-gutters {flex-shrink: 0; display: flex; height: 100%; box-sizing: border-box; inset-inline-start: 0; z-index: 200;}
.ͼ2 .cm-gutters {background-color: #f5f5f5; color: #6c6c6c; border-right: 1px solid #ddd;}
.ͼ3 .cm-gutters {background-color: #333338; color: #ccc;}
.ͼ1 .cm-gutter {display: flex !important; flex-direction: column; flex-shrink: 0; box-sizing: border-box; min-height: 100%; overflow: hidden;}
.ͼ1 .cm-gutterElement {box-sizing: border-box;}
.ͼ1 .cm-lineNumbers .cm-gutterElement {padding: 0 3px 0 5px; min-width: 20px; text-align: right; white-space: nowrap;}
.ͼ2 .cm-activeLineGutter {background-color: #e2f2ff;}
.ͼ3 .cm-activeLineGutter {background-color: #222227;}
.ͼ1 .cm-panels {box-sizing: border-box; position: sticky; left: 0; right: 0;}
.ͼ2 .cm-panels {background-color: #f5f5f5; color: black;}
.ͼ2 .cm-panels-top {border-bottom: 1px solid #ddd;}
.ͼ2 .cm-panels-bottom {border-top: 1px solid #ddd;}
.ͼ3 .cm-panels {background-color: #333338; color: white;}
.ͼ1 .cm-tab {display: inline-block; overflow: hidden; vertical-align: bottom;}
.ͼ1 .cm-widgetBuffer {vertical-align: text-top; height: 1em; width: 0; display: inline;}
.ͼ1 .cm-placeholder {color: #888; display: inline-block; vertical-align: top;}
.ͼ1 .cm-highlightSpace:before {content: attr(data-display); position: absolute; pointer-events: none; color: #888;}
.ͼ1 .cm-highlightTab {background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>'); background-size: auto 100%; background-position: right 90%; background-repeat: no-repeat;}
.ͼ1 .cm-trailingSpace {background-color: #ff332255;}
.ͼ1 .cm-button {vertical-align: middle; color: inherit; font-size: 70%; padding: .2em 1em; border-radius: 1px;}
.ͼ2 .cm-button:active {background-image: linear-gradient(#b4b4b4, #d0d3d6);}
.ͼ2 .cm-button {background-image: linear-gradient(#eff1f5, #d9d9df); border: 1px solid #888;}
.ͼ3 .cm-button:active {background-image: linear-gradient(#111, #333);}
.ͼ3 .cm-button {background-image: linear-gradient(#393939, #111); border: 1px solid #888;}
.ͼ1 .cm-textfield {vertical-align: middle; color: inherit; font-size: 70%; border: 1px solid silver; padding: .2em .5em;}
.ͼ2 .cm-textfield {background-color: white;}
.ͼ3 .cm-textfield {border: 1px solid #555; background-color: inherit;}
.ͼ1 .cm-foldPlaceholder {background-color: #eee; border: 1px solid #ddd; color: #888; border-radius: .2em; margin: 0 1px; padding: 0 1px; cursor: pointer;}
.ͼ1 .cm-foldGutter span {padding: 0 1px; cursor: pointer;}
 
.pandoc-plugin-error {
    color: red;
}
 undefined
</style>
    </head>
    <body>
<h1 data-heading="摘要" dir="auto">摘要</h1>
<p dir="auto">本文档适用于在无网的情况下手动部署的MySQL。任何版本均可按照如下步骤进行部MySQL。</p>
<p dir="auto">并且还讲解了如何修改数据库root账号的密码；以及如何开启mysql远程访问权限，允许远程连接。</p>
<h1 data-heading="一、安装前准备工作" dir="auto">一、安装前准备工作</h1>
<ol dir="auto">
<li dir="auto">
<p dir="auto">确认目前服务器上是否存在MySQL</p>
<p dir="auto">命令：<code>rpm -qa | grep mysql</code></p>
</li>
</ol>
<blockquote dir="auto">
<p dir="auto">说明：若返回空信息，就说明当前环境没有安装MySQL；直接跳到第4步操作后续。</p>
</blockquote>
<ol start="2" dir="auto">
<li dir="auto">
<p dir="auto">检查当前环境是否有自带的mariadb数据库</p>
<pre dir="auto"><code>命令：`rpm -qa | grep mariadb`
</code><button class="copy-code-button">复制</button></pre>
<p dir="auto"><img alt="Pasted image 20240619124925.png" src="Pasted image 20240619124925.png" class="internal-embed"></p>
</li>
</ol>
<blockquote dir="auto">
<p dir="auto">说明：若返回空信息，就说明当前环境没有安装mariadb；跳到下面的步骤安装。</p>
</blockquote>
<ol start="3" dir="auto">
<li dir="auto">
<p dir="auto">若存在mysql或者mariadb则删除<br>
命令：<code>rpm -e --nodeps 安装包名称</code><br>
<img alt="Pasted image 20240619124958.png" src="Pasted image 20240619124958.png" class="internal-embed"></p>
</li>
<li dir="auto">
<p dir="auto">删除后需要重启服务器，重启后再次检查，若有残留继续以上步骤，直到删除干净<br>
命令：<code>reboot</code></p>
</li>
</ol>
<h1 data-heading="二、开始安装" dir="auto">二、开始安装</h1>
<ol dir="auto">
<li dir="auto">
<p dir="auto">创建目录并进入<br>
命令：</p>
<pre dir="auto"><code>	mkdir /usr/local/mysql8
	cd /usr/local/mysql8
</code><button class="copy-code-button">复制</button></pre>
</li>
<li dir="auto">
<p dir="auto">上传安装文件到上述目录，并解压<br>
解压：<code>tar -xvf mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar</code></p>
</li>
<li dir="auto">
<p dir="auto">按照以下顺序进行安装，安装过程中可能会有依赖问题，请参考解决方案<br>
命令：</p>
</li>
</ol>
<pre dir="auto"><code># -i 安装 -v 列出更多详细信息 -h 安装时列出hash标记
rpm -ivh mysql-community-common-8.4.0-1.el7.x86_64.rpm  

rpm -ivh mysql-community-client-plugins-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.4.0-1.el7.x86_64.rpm 

rpm -ivh mysql-community-libs-compat-8.4.0-1.el7.x86_64.rpm 

rpm -ivh mysql-community-client-8.4.0-1.el7.x86_64.rpm 

rpm -ivh mysql-community-icu-data-files-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-debuginfo-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-debug-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.4.0-1.el7.x86_64.rpm 

rpm -ivh mysql-community-embedded-compat-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-devel-8.4.0-1.el7.x86_64.rpm

rpm -ivh mysql-community-test-8.4.0-1.el7.x86_64.rpm
</code><button class="copy-code-button">复制</button></pre>
<ol start="4" dir="auto">
<li dir="auto">安装完成<br>
命令：</li>
</ol>
<pre dir="auto"><code># 查看mysql服务运行状态
systemctl status mysqld

# 启动mysqld服务
systemctl start mysqld

# 查看临时密码
grep -i password /var/log/mysqld.log

# 使用临时密码登录
mysql -u root -p'密码'
</code><button class="copy-code-button">复制</button></pre>
<ol start="5" dir="auto">
<li dir="auto">让MySQL加入开机启动<br>
命令：</li>
</ol>
<pre dir="auto"><code># 加入开机启动
systemctl enable  mysqld

</code><button class="copy-code-button">复制</button></pre>
<h2 data-heading="解决安装过程中依赖缺失的问题" dir="auto">解决安装过程中依赖缺失的问题</h2>
<blockquote dir="auto">
<p dir="auto">针对rpm无法安装的包，提示缺少依赖的，可以依照此法解决</p>
</blockquote>
<ol dir="auto">
<li dir="auto">创建ISO文件存放目录和挂载目录<br>
命令：<code>mkdir /data 命令：</code>mkdir /data/iso<code> 命令：</code>mkdir /mnt/disc`</li>
<li dir="auto">将ISO文件上传到<code>/data/iso</code>中</li>
<li dir="auto">挂载ISO文件<br>
命令：<code>mount -o loop /data/iso/操作系统的.iso /mnt/disc</code></li>
<li dir="auto">创建repo文件，并写入脚本<br>
命令：<code>vim /etc/yum.repos.d/rhel7.repo</code></li>
<li dir="auto">写入脚本</li>
</ol>
<pre dir="auto"><code>[rhel-media] 
name=Red Hat Enterprise Linux 7.0 
baseurl=file:///mnt/disc/ 
enabled=1 
gpgcheck=1 
gpgkey=file:///mnt/disc/RPM-GPG-KEY-redhat-release
</code><button class="copy-code-button">复制</button></pre>
<ol start="6" dir="auto">
<li dir="auto">清理yum源缓存&nbsp;<code>yum clean all</code></li>
<li dir="auto">创建yum源缓存&nbsp;<code>yum makecache</code></li>
<li dir="auto">继续安装之前安装失败的包，此时安装不用rpm使用yum<br>
命令：<code>yum install 包名</code></li>
</ol>
    </body>
</html>